public class Main {
    public static void main(String[] args) {
        Object s1 = "Hello world!";
        if (s1 instanceof String){
            System.out.println(((String) s1).indexOf("!"));
        }
        if (s1 instanceof String tmp){
            System.out.println(tmp.indexOf("!"));
        }

        var s2 = "Hello world!";
        if (s2 instanceof String){
            System.out.println(s2.indexOf("!"));
        }
        if (s2 instanceof String tmp){
            System.out.println(tmp.indexOf("!"));
        }

        System.out.println(s1);
    }
}
